package day22_3;

import java.util.HashSet;
import java.util.LinkedList;
import java.util.Queue;

/**
 * @ClassName Solution
 * @Description TODO
 * @Author clockTown
 * @Date 2021/5/31 19:54
 * @Version 1.0
 */
public class Solution1 {

    public static int lengthOfLongestSubstring(String s) {
        if (s == null || s.length() <= 0) {
            return 0;
        }


        int count = 0, fast = 0;
        String t = "";

        while (fast < s.length()){
            int index = t.indexOf(s.charAt(fast));
            if (index != - 1) {
                t = t.substring(index + 1);
            }
            t += s.charAt(fast);
            fast++;
            count = Math.max(t.length(), count);
        }
        return count;
    }

    public static void main(String[] args) {
        String s = " ";
        int res = lengthOfLongestSubstring(s);
        System.out.println(res);
    }
}
